#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2021/3/12 18:47
# @Author  : cjw
from os.path import dirname, join
from selenium.webdriver.common.by import By

# ------------------------项目地址----------------------------
# 桃李云校登录地址
SCHOOL_URL = 'https://user.tlischool.com/login'
SCHOOL_ADMIN_URL = 'https://user.tlischool.com/user/login'

# ---------------------项目包和文件夹的路径----------------------
"""环境切换后不需要更改配置，直接使用"""

# 项目根目录
BASE_PATH = dirname(dirname(__file__))

# 浏览器驱动地址
CHROME_DRIVER_PATH = join(BASE_PATH, 'drivers', 'chromedriver.exe')
EDGE_DRIVER_PATH = join(BASE_PATH, 'drivers', 'edge_driver.exe')
FIREFOX_DRIVER_PATH = join(BASE_PATH, 'drivers', 'geckodriver.exe')
IE_DRIVER_PATH = join(BASE_PATH, 'drivers', 'IEDriverServer_32.exe')
OPERA_DRIVER_PATH = join(BASE_PATH, 'drivers', 'opera_driver.exe')

# 测试报告路径
REPORT_PATH = join(BASE_PATH, 'report')
# 测试数据路径
DATA = join(BASE_PATH, 'data')
# 测试案例路径
CASE_PATH = join(BASE_PATH, 'case')
# 数据库配置文件路径
DATABASE_INI_PATH = join(BASE_PATH, 'config', 'database.ini')

# -------------------------浏览器对象属性-------------------------
"""浏览器共有属性"""
# 无头化
HEADLESS = False

# 隐式等待时间
IMPLICIT_WAIT_TIME = 2
# 显示等待时间
WEBDRIVER_WAIT_TIMEOUT = 10
# 页面加载超时时间
PAGE_LOAD_TIME = 10
# JS异步执行超时时间
SCRIPT_TIMEOUT = 10
# 浏览器启动尺寸
WINDOWS_SIZE = (1920, 1024)

"""谷歌浏览器特有属性"""
# 浏览器特性操作开关
CHROME_METHOD_MARK = True
# 启动参数开关
CHROME_OPTION_MARK = True
# 实验选项
CHROME_EXPERIMENTAL_OPTION = {
	'excludeSwitches': ['enable-automation'],  # 不显示自动化软件控制提示
	# 'mobileEmulation': {'deviceName': 'iPhone 6'}  # 以移动手机型号打开网页，测试H5网页有用
	'prefs': {  # 取消密码自动保存提示
		'credentials_enable_service': False,
		'profile.password_manager_enabled': False
	}
}
# 窗口大小启动参数
CHROME_WINDOW_SIZE = (1920, 900)
# 启动窗口最大化
CHROME_START_MAXIMIZED = '--start-maximized'

"""IE浏览器特有属性"""
# 清空本地会话
IE_CLEAN_SESSION = True
# 忽略浏览器的缩放设置
IE_IGNORE_ZOOM_SETTING = True
# 浏览器操作开关
IE_METHOD_MARK = True
# 启动参数开关
IE_OPTION_MARK = True
# 页面超时时间
IE_ATTACH_TIMEOUT = 10000

# -------------------------YAML元素配置文件-------------------------
# 元素配置根目录
ELEMENTS_YAML_FILE_PATH = join(BASE_PATH, 'business', 'page')
YAML_ELEMENT = {
	'lp': join(ELEMENTS_YAML_FILE_PATH, 'login_page.yml'),
	'dmp': join(ELEMENTS_YAML_FILE_PATH, 'department_management_page.yml')
}

# -------------------------WEB元素定位方法-------------------------
BY_RULES = (
	By.ID,
	By.XPATH,
	By.NAME,
	By.TAG_NAME,
	By.CLASS_NAME,
	By.LINK_TEXT,
	By.PARTIAL_LINK_TEXT,
	By.CSS_SELECTOR
)

# -----------------------------邮箱配置-----------------------------
MAIL_SERVER = 'smtp.qq.com'
MAIL_PORT = 465
MAIL_USERNAME = ('xxx', 'xxx@qq.com')
MAIL_PASSWORD = 'xxxxxxxxx'

if __name__ == '__main__':
	print(REPORT_PATH)
